#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e7+10;

char s[N],t[N];
int n,f[N],dp[N],can[N];

void solve(){
	scanf("%s",s+1); n = strlen(s+1);
	int m = 0;t[m] = '$';t[++m] = '#';
	for(int i = 1;i <= n;i++) t[++m] = s[i],t[++m] = '#';
	t[++m] = '~';
	memset(f,0,sizeof(f)); memset(dp,0,sizeof(dp));
	int p = 0,l = 0;
	for(int i = 0;i <= m;i++) {
		if(i < l) f[i] = min(f[p*2-i],l-i);else f[i] = 1;
		while(t[i-f[i]] == t[i+f[i]] && f[i] + i <= m) f[i]++;
		if(i+f[i] > l) l = i + f[i],p = i;
	}
	for(int i = 1;i <= n;i++) can[i] = (f[i*2] + 1)/2;
//	for(int i = 1;i <= n;i++) cout<<i<<".."<<can[i]<<endl;
	for(int i = n;i >= 1;i--){
		if(i * 2 > n) dp[i] = can[i] + i > n;
		else if(can[i] == i) dp[i] = dp[i+can[i]-1];
	}
	for(int i = 1;i <= n;i++) if(dp[i]) printf("%d ",i);
	puts("");
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	int t = in;
	while(t--) solve();
	return 0;
}

